<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    request.setCharacterEncoding("UTF-8");
    String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
    <style type="text/css">
        input[type=checkbox] {
            padding: 0px;
            margin: 0px;
            text-align: right;
            width: 15px
        }

        .div_zilei {
            width: 600px;
            padding-left: 90px;
            height: 30px
        }

        .tr {
            height: 40px;
            background: #a9bbe0
        }

        .tr td {
            font-size: 14px;
            color: #ffffff
        }

        .tr_td {
            height: 40px;
        }

        .tr_td td {
            border-bottom: 1px solid #ededed;
            text-align: center;
        }

        tr td:nth-child(1) {
            font-size: 14px;
            color: #cccccc
        }

        .date {
            border: 0;
            background: #ffffff;
            text-align: center;
        }

        .tr_td td:nth-child(1) {
            border-left: 1px solid #cccccc;
        }

        .addTable.deleteTable:HOVER {
            cursor: pointer;
        }

        .fseq {
            width: 37px;
            border: 0;
            text-align: center;
            color: #cccccc
        }

        .jczl {
            padding-left: 100px;
        }

        .div_tj {
            margin-top: 0px;
            margin-left: 140px;
            padding-right: 60px;
        }

        .text {
            border: 0;
            background: #ffffff;
            text-align: center;
        }
        .div_input {
            width: 500px;
            height: 40px;
        }
    </style>
</head>
<body style="background: #f5f5f5">
<div class="main">
    <div class="weizhi">
        基础资料>>财务基础资料>>协议驾校>>新增
    </div>
    <%--提示的隐藏标识--%>
    <input type="hidden" id="alertType" value="${alertType}">
    <div class="div_body" style="box-shadow: 0 0 5px #cccccc;">
        <div class="div_form">
            <div class="fwrz">
                <div class="div_input">
                    <span class="gn_name">驾校&nbsp;:&nbsp;</span>
                    <input type="text" readonly="readonly" name="fcontrolunitid" value="${fnamel2}"
                           style="color: gray;">
                </div>
                <div class="div_input">
                    <span class="gn_name">编码&nbsp;:&nbsp;</span>
                    <input id="fnumber" type="text" name="fnumber" readonly="readonly" value="${fnumber}"
                           style="color: gray;">
                </div>
                <div class="div_input">
                    <span class="gn_name">名称&nbsp;:&nbsp;</span>
                    <input id="fnameL2" class="is_click" type="text" name="fnameL2" style="color: gray;">
                    <span class="required">必填</span>
                </div>
                <div class="div_input">
                    <span class="gn_name">简称&nbsp;:&nbsp;</span>
                    <input id="fsimplename" type="text" name="fsimplename">
                </div>
                <div class="div_input">
                    <span class="gn_name">描述&nbsp;:&nbsp;</span>
                    <input type="text" name="fdescriptionL2" id="fdescriptionL2">
                    <span style="font-size: 14px;color: red;display: none" class="haoyou">请输入数字</span>
                </div>

            </div>
            <div class="div_zilei">
                <div style="width: 380px;text-align: right;float: left;">
                    <img src="<%=path%>/image/insert2323.jpg" class="addTable">
                    <span style="padding-right: 20px;color: #a9bbe0;font-size: 14px" class="addTable">添加</span>
                    <img src="<%=path%>/image/delete212.png" class="deleteTable">
                    <span class="deleteTable" style="color: #a9bbe0;font-size: 14px"
                          class="deleteTable">删除</span>
                </div>
            </div>
            <div style="overflow:auto;height: 230px;width: 750px;">
                <table width="100%" id="table1"
                       style="min-height:50px;overflow:hidden;border-spacing:0;">
                    <tr class="tr">
                        <td width="45px" align="center" class='fseq'>序号</td>
                        <td width="150px" align="center">车牌</td>
                        <td width="150px" align="center">车型</td>
                        <td width="150px" align="center">备注</td>
                    </tr>
                    <tr align='left' class='tr_td'>
                        <td><input type='text' name='fseq' class='fseq' value="1" readonly='readonly'></td>
                        <td><input type='text' name='car_input1' class='text'/></td>
                        <td><input type='text' name='car_input2' class='text'/></td>
                        <td><input type='text' name='car_input3' class='text'/></td>
                    </tr>
                </table>
            </div>
        </div>
            <div class="div_tj">
                <div>
                    <input type="submit" class="input_submit bc" value="" style="margin-top: 0px;margin-right: 30px"/>
                </div>
                <div>
                    <input type="button" class="input_back fh" value="" onclick="back()" style="margin-top: 0px;"/>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<script>

    var updateid = new Array();

    $(".addTable").click(function () {
        var tr_len = $("#table1 tr").length;//表格长度
        var str = "<tr align='left' class='tr_td'><td><input type='text' name='fseq' class='fseq' value=" + tr_len + " readonly='readonly'></td>"
        str += "<td><input type='text' name='car_input1' class='text'/></td>"
        str += "<td><input type='text' name='car_input2' class='text'/></td>"
        str += "<td><input type='text' name='car_input3' class='text'/></td></tr>"
        $("#table1").append(str)
    })

    //删除一行
    $(".deleteTable").click(function () {
        var tr_len = $("#table1 tr").length;
        if (tr_len == 2) {
            alert("最后一行不能删除")
        } else {
            updateid.push($('#table1 input:first').val())
            $('#table1 tr:last').remove();
        }
    })

    $(".input_submit").click(function () {

        var fid = $("#fid").val();//fid
        var fnumber = $("#fnumber").val();//名称
        var fnameL2 = $("#fnameL2").val();//名称
        var fsimplename = $("#fsimplename").val();//简称
        var fdescriptionL2 = $("#fdescriptionL2").val();//描述

        var cfchepiao = new Array();
        var cfchexing = new Array();
        var cfdesc = new Array();
        var didarr = new Array();//车辆的fid
        var fseqarr = new Array();//车辆的fid

        var car_input1 = document.getElementsByName("car_input1");
        var car_input2 = document.getElementsByName("car_input2");
        var car_input3 = document.getElementsByName("car_input3");
        var did = document.getElementsByName("did");
        var fseq = document.getElementsByName("fseq");

        /*只遍历改变了的数据*/
        for (var i = 0; i < car_input1.length; i++) {
            cfchepiao[i] = car_input1[i].value;
            cfchexing[i] = car_input2[i].value;
            cfdesc[i] = car_input3[i].value;
            if (typeof(did[i]) != "undefined")
                didarr[i] = did[i].value;
            fseqarr[i] = fseq[i].value;
        }

        if ($('.is_click').val() == "") {
            alert('必填项不能为空！');
            return false;
        }
        location = 'add_driving?fseq=' + fseqarr + '&updateid=' + updateid + '&did=' + didarr + '&fid=' + fid + '&fnumber=' + fnumber + '&fnameL2=' + fnameL2 + '&fsimplename=' + fsimplename + '&fdescriptionL2='
            + fdescriptionL2 + '&cfchepiao=' + cfchepiao + '&cfchexing=' + cfchexing + '&cfdesc=' + cfdesc + '';
    })

    //返回
    function back() {
        location = '<%=path%>/DrivingSys/select_driving/look.action'
    }

</script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
</html>